package br.edu.sistemaacademico;

import javax.swing.JMenuItem;
import javax.swing.JOptionPane;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
import javax.swing.text.Document;

import br.edu.sistemaacademico.Decorator.ConcretDecorator;
import br.edu.sistemaacademico.adapter.IMenuCadastro;
import br.edu.sistemaacademico.observer.Observavel;
import br.edu.sistemaacademico.observer.Observer;
import br.edu.sistemaacademico.observer.ValidaEspecial;
import br.edu.sistemaacademico.pojo.Servidor;
import client.ClientCommand;

public class frmCadastroServidor extends IMenuCadastro {

    Servidor servidor = new Servidor();
    ConcretDecorator cc = null;
    public frmCadastroServidor() {
            execute();
    }

        @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jScrollPane1 = new javax.swing.JScrollPane();
        jPanel2 = new javax.swing.JPanel();
        jLabel7 = new javax.swing.JLabel();
        JtbRG1 = new javax.swing.JTextField();
        jLabel8 = new javax.swing.JLabel();
        jtbDtNasc1 = new javax.swing.JTextField();
        jLabel11 = new javax.swing.JLabel();
        jLabel12 = new javax.swing.JLabel();
        jLabel13 = new javax.swing.JLabel();
        JtbLogin1 = new javax.swing.JTextField();
        jLEndereco1 = new javax.swing.JLabel();
        JtbSenha1 = new javax.swing.JPasswordField();
        jTEndereco1 = new javax.swing.JTextField();
        jLCidade1 = new javax.swing.JLabel();
        jTCPF1 = new javax.swing.JTextField();
        JtbSenharetry1 = new javax.swing.JPasswordField();
        jLTelefone1 = new javax.swing.JLabel();
        jLabel14 = new javax.swing.JLabel();
        jTTelefone1 = new javax.swing.JTextField();
        JtbCTPS1 = new javax.swing.JTextField();
        infoBairro7 = new javax.swing.JLabel();
        infoBairro8 = new javax.swing.JLabel();
        infoBairro9 = new javax.swing.JLabel();
        infoBairro10 = new javax.swing.JLabel();
        jTsexo1 = new javax.swing.JTextField();
        infoBairro11 = new javax.swing.JLabel();
        jLBairro1 = new javax.swing.JLabel();
        infoBairro12 = new javax.swing.JLabel();
        infoTelefone1 = new javax.swing.JLabel();
        infoBairro13 = new javax.swing.JLabel();
        infoCidade1 = new javax.swing.JLabel();
        infoEndereco1 = new javax.swing.JLabel();
        jtbCargo1 = new javax.swing.JTextField();
        jBCancelar1 = new javax.swing.JButton();
        jBCadastrar1 = new javax.swing.JButton();
        jLabel15 = new javax.swing.JLabel();
        JtbEscolaridade1 = new javax.swing.JTextField();
        jLabel16 = new javax.swing.JLabel();
        jLNome1 = new javax.swing.JLabel();
        jTNome1 = new javax.swing.JTextField();
        infoNome1 = new javax.swing.JLabel();

        setPreferredSize(new java.awt.Dimension(542, 424));

        jPanel2.setPreferredSize(new java.awt.Dimension(522, 594));

        jLabel7.setText("RG");

        JtbRG1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                JtbRGActionPerformed(evt);
            }
        });

        jLabel8.setText("Senha");

        jLabel11.setText("Data Nascimento");

        jLabel12.setText("Login");

        jLabel13.setText("Repita Senha");

        jLEndereco1.setText("Endereco");

        JtbSenha1.setText("jPasswordField1");

        jLCidade1.setText("CPF");

        JtbSenharetry1.setText("jPasswordField2");

        jLTelefone1.setText("Telefone");

        jLabel14.setText("CTPS");

        jTTelefone1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTTelefoneActionPerformed(evt);
            }
        });

        infoBairro7.setFont(new java.awt.Font("Tahoma", 0, 9));
        infoBairro7.setText("* Campo Obrigatorio");

        infoBairro8.setFont(new java.awt.Font("Tahoma", 0, 9));
        infoBairro8.setText("* Campo Obrigatorio");

        infoBairro9.setFont(new java.awt.Font("Tahoma", 0, 9));
        infoBairro9.setText("* Campo Obrigatorio");

        infoBairro10.setFont(new java.awt.Font("Tahoma", 0, 9));
        infoBairro10.setText("* Campo Obrigatorio");

        jTsexo1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTsexoActionPerformed(evt);
            }
        });

        infoBairro11.setFont(new java.awt.Font("Tahoma", 0, 9));
        infoBairro11.setText("* Campo Obrigatorio");

        jLBairro1.setText("Sexo");

        infoBairro12.setFont(new java.awt.Font("Tahoma", 0, 9));
        infoBairro12.setText("* Campo Obrigatorio");

        infoTelefone1.setFont(new java.awt.Font("Tahoma", 0, 9));
        infoTelefone1.setText(" ");

        infoBairro13.setFont(new java.awt.Font("Tahoma", 0, 9));
        infoBairro13.setText("* Campo Obrigatorio");

        infoCidade1.setFont(new java.awt.Font("Tahoma", 0, 9));
        infoCidade1.setText("* Campo Obrigatorio");

        infoEndereco1.setFont(new java.awt.Font("Tahoma", 0, 9));
        infoEndereco1.setText("* Campo Obrigatorio");

        jBCancelar1.setText("Cancelar");
        jBCancelar1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jBCancelarActionPerformed(evt);
            }
        });

        jBCadastrar1.setText("Cadastrar");
        jBCadastrar1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jBCadastrarActionPerformed(evt);
            }
        });

        jLabel15.setText("Cargo");

        jLabel16.setText("Escolaridade");

        jLNome1.setText("Nome");

        infoNome1.setFont(new java.awt.Font("Tahoma", 0, 9));
        infoNome1.setText("* Campo Obrigatorio");

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(jPanel2Layout.createSequentialGroup()
                            .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addGroup(jPanel2Layout.createSequentialGroup()
                                    .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                        .addGroup(jPanel2Layout.createSequentialGroup()
                                            .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                                .addComponent(jLEndereco1)
                                                .addComponent(jLCidade1)
                                                .addComponent(jLabel7)
                                                .addComponent(jLabel14)
                                                .addComponent(jLTelefone1))
                                            .addGap(18, 18, 18)
                                            .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                                .addGroup(jPanel2Layout.createSequentialGroup()
                                                    .addComponent(jTTelefone1, javax.swing.GroupLayout.PREFERRED_SIZE, 150, javax.swing.GroupLayout.PREFERRED_SIZE)
                                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 251, javax.swing.GroupLayout.PREFERRED_SIZE))
                                                .addGroup(jPanel2Layout.createSequentialGroup()
                                                    .addComponent(infoEndereco1)
                                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 301, javax.swing.GroupLayout.PREFERRED_SIZE))
                                                .addGroup(jPanel2Layout.createSequentialGroup()
                                                    .addComponent(infoCidade1)
                                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 301, javax.swing.GroupLayout.PREFERRED_SIZE))
                                                .addGroup(jPanel2Layout.createSequentialGroup()
                                                    .addComponent(jTEndereco1, javax.swing.GroupLayout.PREFERRED_SIZE, 303, javax.swing.GroupLayout.PREFERRED_SIZE)
                                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 98, javax.swing.GroupLayout.PREFERRED_SIZE))
                                                .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
                                                    .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                                        .addGroup(jPanel2Layout.createSequentialGroup()
                                                            .addComponent(jTCPF1, javax.swing.GroupLayout.DEFAULT_SIZE, 263, Short.MAX_VALUE)
                                                            .addGap(38, 38, 38))
                                                        .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel2Layout.createSequentialGroup()
                                                            .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                                                .addComponent(infoBairro13)
                                                                .addComponent(JtbRG1, javax.swing.GroupLayout.DEFAULT_SIZE, 289, Short.MAX_VALUE)
                                                                .addComponent(JtbCTPS1, javax.swing.GroupLayout.DEFAULT_SIZE, 289, Short.MAX_VALUE))
                                                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)))
                                                    .addComponent(jLBairro1)
                                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                                    .addComponent(jTsexo1, javax.swing.GroupLayout.PREFERRED_SIZE, 27, javax.swing.GroupLayout.PREFERRED_SIZE)
                                                    .addGap(27, 27, 27))
                                                .addGroup(jPanel2Layout.createSequentialGroup()
                                                    .addComponent(infoBairro8)
                                                    .addGap(9, 9, 9))
                                                .addComponent(jTNome1, javax.swing.GroupLayout.DEFAULT_SIZE, 401, Short.MAX_VALUE)
                                                .addGroup(jPanel2Layout.createSequentialGroup()
                                                    .addComponent(infoBairro7)
                                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 301, javax.swing.GroupLayout.PREFERRED_SIZE))
                                                .addComponent(infoNome1)))
                                        .addGroup(jPanel2Layout.createSequentialGroup()
                                            .addComponent(jLabel13)
                                            .addGap(38, 38, 38)
                                            .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                                .addComponent(infoBairro12)
                                                .addComponent(JtbSenharetry1, javax.swing.GroupLayout.PREFERRED_SIZE, 121, javax.swing.GroupLayout.PREFERRED_SIZE)))
                                        .addGroup(jPanel2Layout.createSequentialGroup()
                                            .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                                .addComponent(jLabel11)
                                                .addComponent(jLabel12)
                                                .addComponent(jLabel8))
                                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                            .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                                .addComponent(infoBairro10)
                                                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                                                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel2Layout.createSequentialGroup()
                                                        .addComponent(jtbDtNasc1, javax.swing.GroupLayout.PREFERRED_SIZE, 83, javax.swing.GroupLayout.PREFERRED_SIZE)
                                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 265, Short.MAX_VALUE))
                                                    .addComponent(infoBairro9, javax.swing.GroupLayout.Alignment.LEADING)
                                                    .addComponent(infoBairro11, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 348, Short.MAX_VALUE)
                                                    .addComponent(JtbSenha1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, 131, javax.swing.GroupLayout.PREFERRED_SIZE)
                                                    .addComponent(JtbLogin1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, 131, javax.swing.GroupLayout.PREFERRED_SIZE)))))
                                    .addGap(23, 23, 23))
                                .addComponent(jLNome1))
                            .addGap(22, 22, 22))
                        .addGroup(jPanel2Layout.createSequentialGroup()
                            .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addGroup(jPanel2Layout.createSequentialGroup()
                                    .addGap(133, 133, 133)
                                    .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                        .addComponent(JtbEscolaridade1, javax.swing.GroupLayout.DEFAULT_SIZE, 348, Short.MAX_VALUE)
                                        .addComponent(jtbCargo1, javax.swing.GroupLayout.DEFAULT_SIZE, 348, Short.MAX_VALUE)))
                                .addGroup(jPanel2Layout.createSequentialGroup()
                                    .addComponent(jLabel16)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 439, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addGroup(jPanel2Layout.createSequentialGroup()
                                    .addComponent(jLabel15)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 488, javax.swing.GroupLayout.PREFERRED_SIZE)))
                            .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
                        .addComponent(jBCadastrar1)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jBCancelar1)
                        .addGap(34, 34, 34))))
            .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(jPanel2Layout.createSequentialGroup()
                    .addGap(210, 210, 210)
                    .addComponent(infoTelefone1)
                    .addGap(279, 279, 279)))
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(infoNome1)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLNome1)
                    .addComponent(jTNome1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addComponent(infoEndereco1)
                        .addGap(2, 2, 2)
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLEndereco1)
                            .addComponent(jTEndereco1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel2Layout.createSequentialGroup()
                                .addGap(5, 5, 5)
                                .addComponent(infoCidade1)
                                .addGap(3, 3, 3)
                                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jLCidade1)
                                    .addComponent(jTCPF1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(infoBairro13)
                                .addGap(2, 2, 2)
                                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jLabel7)
                                    .addComponent(JtbRG1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                            .addGroup(jPanel2Layout.createSequentialGroup()
                                .addGap(18, 18, 18)
                                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                    .addComponent(jLBairro1)
                                    .addComponent(jTsexo1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))))
                        .addGap(6, 6, 6)
                        .addComponent(infoBairro7)
                        .addGap(2, 2, 2)
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(JtbCTPS1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel14))
                        .addGap(22, 22, 22)
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jTTelefone1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLTelefone1)))
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addGap(144, 144, 144)
                        .addComponent(infoBairro8)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(infoBairro9)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jtbDtNasc1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel11))
                .addGap(6, 6, 6)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addComponent(infoBairro10)
                        .addGap(2, 2, 2)
                        .addComponent(JtbLogin1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(infoBairro11)
                        .addGap(1, 1, 1)
                        .addComponent(JtbSenha1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(7, 7, 7)
                        .addComponent(infoBairro12)
                        .addGap(1, 1, 1))
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel2Layout.createSequentialGroup()
                        .addGap(12, 12, 12)
                        .addComponent(jLabel12)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(jLabel8)
                        .addGap(18, 18, 18)))
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(JtbSenharetry1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel13))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel16)
                    .addComponent(JtbEscolaridade1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel15)
                    .addComponent(jtbCargo1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jBCadastrar1)
                    .addComponent(jBCancelar1, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(115, Short.MAX_VALUE))
            .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(jPanel2Layout.createSequentialGroup()
                    .addGap(160, 160, 160)
                    .addComponent(infoTelefone1)
                    .addContainerGap(424, Short.MAX_VALUE)))
        );

        jScrollPane1.setViewportView(jPanel2);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 560, javax.swing.GroupLayout.PREFERRED_SIZE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 489, javax.swing.GroupLayout.PREFERRED_SIZE)
        );
    }// </editor-fold>//GEN-END:initComponents

        private void jBCadastrarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBCadastrarActionPerformed

}//GEN-LAST:event_jBCadastrarActionPerformed

        private void jBCancelarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBCancelarActionPerformed

}//GEN-LAST:event_jBCancelarActionPerformed

        private void jTsexoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTsexoActionPerformed
            // TODO add your handling code here:
}//GEN-LAST:event_jTsexoActionPerformed

        private void jTTelefoneActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTTelefoneActionPerformed
            System.out.println("telefone");
}//GEN-LAST:event_jTTelefoneActionPerformed

        private void JtbRGActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_JtbRGActionPerformed
            // TODO add your handling code here:
}//GEN-LAST:event_JtbRGActionPerformed


    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JTextField JtbCTPS;
    private javax.swing.JTextField JtbCTPS1;
    private javax.swing.JTextField JtbEscolaridade;
    private javax.swing.JTextField JtbEscolaridade1;
    private javax.swing.JTextField JtbLogin;
    private javax.swing.JTextField JtbLogin1;
    private javax.swing.JTextField JtbRG;
    private javax.swing.JTextField JtbRG1;
    private javax.swing.JPasswordField JtbSenha;
    private javax.swing.JPasswordField JtbSenha1;
    private javax.swing.JPasswordField JtbSenharetry;
    private javax.swing.JPasswordField JtbSenharetry1;
    private javax.swing.JLabel infoBairro;
    private javax.swing.JLabel infoBairro1;
    private javax.swing.JLabel infoBairro10;
    private javax.swing.JLabel infoBairro11;
    private javax.swing.JLabel infoBairro12;
    private javax.swing.JLabel infoBairro13;
    private javax.swing.JLabel infoBairro2;
    private javax.swing.JLabel infoBairro3;
    private javax.swing.JLabel infoBairro4;
    private javax.swing.JLabel infoBairro5;
    private javax.swing.JLabel infoBairro6;
    private javax.swing.JLabel infoBairro7;
    private javax.swing.JLabel infoBairro8;
    private javax.swing.JLabel infoBairro9;
    private javax.swing.JLabel infoCidade;
    private javax.swing.JLabel infoCidade1;
    private javax.swing.JLabel infoEndereco;
    private javax.swing.JLabel infoEndereco1;
    private javax.swing.JLabel infoNome;
    private javax.swing.JLabel infoNome1;
    private javax.swing.JLabel infoTelefone;
    private javax.swing.JLabel infoTelefone1;
    private javax.swing.JButton jBCadastrar;
    private javax.swing.JButton jBCadastrar1;
    private javax.swing.JButton jBCancelar;
    private javax.swing.JButton jBCancelar1;
    private javax.swing.JLabel jLBairro;
    private javax.swing.JLabel jLBairro1;
    private javax.swing.JLabel jLCidade;
    private javax.swing.JLabel jLCidade1;
    private javax.swing.JLabel jLEndereco;
    private javax.swing.JLabel jLEndereco1;
    private javax.swing.JLabel jLNome;
    private javax.swing.JLabel jLNome1;
    private javax.swing.JLabel jLTelefone;
    private javax.swing.JLabel jLTelefone1;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel15;
    private javax.swing.JLabel jLabel16;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JTextField jTCPF;
    private javax.swing.JTextField jTCPF1;
    private javax.swing.JTextField jTEndereco;
    private javax.swing.JTextField jTEndereco1;
    private javax.swing.JTextField jTNome;
    private javax.swing.JTextField jTNome1;
    private javax.swing.JTextField jTTelefone;
    private javax.swing.JTextField jTTelefone1;
    private javax.swing.JTextField jTsexo;
    private javax.swing.JTextField jTsexo1;
    private javax.swing.JTextField jtbCargo;
    private javax.swing.JTextField jtbCargo1;
    private javax.swing.JTextField jtbDtNasc;
    private javax.swing.JTextField jtbDtNasc1;
    // End of variables declaration//GEN-END:variables
    
    private Observavel docTelefone = new Observavel();
    private Observavel docNome = new Observavel();
    private Observavel docBairro = new Observavel();
    private Observavel docEndereco = new Observavel();
    private Observavel docCidade = new Observavel();


    public void execute() {
         initComponents();
         if (cc==null)
                cc = new ConcretDecorator(this);
          initObserver();
          campoObrigatorio();
//		populaFields(servidor);
          cc.setVisible(true);
    }

    public void initObserver(){
        Observer val = new ValidaEspecial();
        docTelefone.setDocument(jTTelefone.getDocument());
          docNome.setDocument(jTNome.getDocument());
          docBairro.setDocument(jTsexo.getDocument());
          docEndereco.setDocument(jTEndereco.getDocument());
          docCidade.setDocument(jTCPF.getDocument());

          docTelefone.addObserver(val);
          docNome.addObserver(val);
          docBairro.addObserver(val);
          docEndereco.addObserver(val);
          docCidade.addObserver(val);


          jTTelefone.getDocument().addDocumentListener(listener);
          jTNome.getDocument().addDocumentListener(listener);
          jTsexo.getDocument().addDocumentListener(listener);
          jTEndereco.getDocument().addDocumentListener(listener);
          jTCPF.getDocument().addDocumentListener(listener);
    }

    public void setTtelefone(Observavel observavel){
        observavel.setDocument(jTTelefone.getDocument());
        observavel.setChanged();
        observavel.notifyObservers();
        jTTelefone.setDocument(observavel.getDocument());

    }
        public void setTNome(Observavel observavel){
        observavel.setDocument(jTNome.getDocument());
        observavel.setChanged();
        observavel.notifyObservers();
        jTNome.setDocument(observavel.getDocument());
    }
        public void setTBairro(Observavel observavel){
        observavel.setDocument(jTsexo.getDocument());
        observavel.setChanged();
        observavel.notifyObservers();
        jTsexo.setDocument(observavel.getDocument());
    }
        public void setTEndereco(Observavel observavel){
        observavel.setDocument(jTEndereco.getDocument());
        observavel.setChanged();
        observavel.notifyObservers();
        jTEndereco.setDocument(observavel.getDocument());
    }
        public void setTCidade(Observavel observavel){
        observavel.setDocument(jTCPF.getDocument());
        observavel.setChanged();
        observavel.notifyObservers();
        jTCPF.setDocument(observavel.getDocument());
    }

    public void getEventDocument(Document doc){
        if(doc.equals(docTelefone.getDocument()))
                setTtelefone(docTelefone);
        else if(doc.equals(docNome.getDocument()))
                setTNome(docNome);
        else if(doc.equals(docBairro.getDocument()))
                setTBairro(docBairro);
        else if(doc.equals(docEndereco.getDocument()))
                setTEndereco(docEndereco);
        else if(doc.equals(docCidade.getDocument()))
                setTCidade(docCidade);
    }

    public void campoObrigatorio(){
        infoNome.setText("* Campo Obrigatorio");
        infoEndereco.setText("* Campo Obrigatorio");
        infoCidade.setText("* Campo Obrigatorio");
        infoBairro.setText("* Campo Obrigatorio");
    }
    
    DocumentListener listener = new DocumentListener() {

            public void insertUpdate(DocumentEvent e) {
               getEventDocument(e.getDocument());
            }

            public void removeUpdate(DocumentEvent e) {
                getEventDocument(e.getDocument());
            }

            public void changedUpdate(DocumentEvent e) {
                 getEventDocument(e.getDocument());
            }

        };

            public void populaServidor(Servidor o){
        o.setNome(jTNome.getText());
        o.setEndereco(jTEndereco.getText());
        o.setCpf(jTCPF.getText());
        o.setTelefone(jTTelefone.getText());
        o.setSexo(jTsexo.getText().charAt(0));
        o.setRg(JtbRG.getText());
        o.setNascimento(jtbDtNasc.getText());
        o.setLogin(JtbLogin.getText());
        if(JtbSenha.getText().equals(JtbSenharetry.getText()))
        o.setSenha(JtbSenha.getText());
        o.setCtps(JtbCTPS.getText());
        o.setEscolaridade(JtbEscolaridade.getText());
        o.setCargo(jtbCargo.getText());
        //o.setAnosaida(JtbDtSaida.getText());
    }
    public void populaFields(Servidor o){
        jTNome.setText(o.getNome());
        jTEndereco.setText(o.getEndereco());
        jTCPF.setText(o.getCpf());
        jTTelefone.setText(o.getTelefone());
        jTsexo.setText(o.getSexo().toString());
        JtbRG.setText(o.getRg());
        jtbDtNasc.setText(o.getNascimento());
        JtbLogin.setText(o.getLogin());
        JtbSenha.setText(o.getSenha());
        JtbSenharetry.setText(o.getSenha());
        JtbCTPS.setText(o.getCtps());
        JtbEscolaridade.setText(o.getEscolaridade());
        jtbCargo.setText(o.getCargo());
    }
    public void limpaFields(){
        jTNome.setText("");
        jTEndereco.setText("");
        jTCPF.setText("");
        jTTelefone.setText("");
        jTsexo.setText("");
        JtbRG.setText("");
        jtbDtNasc.setText("");
        JtbLogin.setText("");
        JtbSenha.setText("");
        JtbSenharetry.setText("");
        JtbCTPS.setText("");
        JtbEscolaridade.setText("");
        jtbCargo.setText("");
    }

    
	@Override
	public void menuExemplo(JMenuItem item) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void menuFechar(JMenuItem item) {
		cc.dispose();		
	}

	@Override
	public void menuLimpa(JMenuItem item) {
		limpaFields();		
	}

	@Override
	public void menuManual(JMenuItem item) {
		// TODO Auto-generated method stub		
	}

	@Override
	public void menuMementor(JMenuItem item) {
		// TODO Auto-generated method stub		
	}

	@Override
	public void menuOperacao(JMenuItem item) {
		item.setText("Cadastrar Servidor");
		operacao();
	}

	@Override
	public void menuSobre(JMenuItem item) {
		// TODO Auto-generated method stub
		
	}
	
	public void operacao(){
		populaServidor(servidor);
        if(ClientCommand.gravar("ServidorService",servidor)==true)
        	JOptionPane.showMessageDialog(null, "Servidor Cadastrado com sucesso");
        limpaFields();
	}

}
